import { createBrowserRouter } from 'react-router-dom';
import Login from '../page/Login';
import Article from '../page/Article';
import Layout from '../page/Layout';
import About from '../page/About';
import Board from '../page/Board';
import Keyboard from '../page/Keyboard';
import NotFound from '../page/NotFound';
import Nav from '../page/Nav';

// 创建router实例对象并配置路由对应关系
const routes = [
  {
    path: '/',
    element: <Layout />,
    children: [
      {
        index: true,
        element: <Nav />,
      },
      {
        path: '/board',
        element: <Board />,
      },
    ],
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '/about',
    element: <About />,
  },
  {
    path: '/keyboard',
    element: <Keyboard />,
    meta: {
      title: '键盘事件',
    },
  },
  {
    path: '/article/:id',
    element: <Article />,
  },
  {
    path: '*',
    element: <NotFound />,
  },
];
const basename = import.meta.env.VITE_APP_BASE_URL || '/';
export default createBrowserRouter(routes, {});
